package ch9.inner;

import java.util.Date;

public class Hotel {
	private String name, addr, tele;

	Zhizhao z = new Zhizhao("包河区工商局", "2019-1至2025-12", "皖和3943939393");

	public Hotel(String name, String addr, String tele) {
		super();
		this.name = name;
		this.addr = addr;
		this.tele = tele;
		// z.show();
	}

	// 普通内部类：定义在类里面，不在任何一个方法的里面
	public class Zhizhao {
		private String banfajigou;
		private String qixian;
		private String no;

		public Zhizhao(String banfajigou, String qixian, String no) {
			super();
			this.banfajigou = banfajigou;
			this.qixian = qixian;
			this.no = no;
		}

		public void show() {
			System.out.println("执照号：" + no);
			System.out.println("办法机构：" + banfajigou);
			System.out.println("有效期：" + qixian);
			// 内部类中可以直接访问外部类的属性和方法
			System.out.println("颁发给：" + name + ",经营地址在：" + addr + ",电话：" + tele);
			// show();
			// !!!!!!每一个内部类都持有一个外部类的引用
			// 访问的方式：外部类名字·this
			Hotel.this.show();
		}
	}

	public void show() {
		System.out.println("这个宾馆名叫：" + name + "，位于" + addr + ",电话是：" + tele);

	}

	// 方法内部类
	public void clean(String roomNo) {
		Date d = new Date();
		class Cleaner {
			private String name, tele;

			public Cleaner(String name, String tele) {
				super();
				this.name = name;
				this.tele = tele;
			}

			@Override
			public String toString() {
				return "保洁工 [name=" + name + ", tele=" + tele + "]";
			}

			public void doClean() {
				// roomNo = "402";// roomno是fianl
				System.out.println(name + "，在时间" + d + "，在" + Hotel.this.name + ",清洁了" + roomNo);
			}
		}

		Cleaner c = new Cleaner("王大妈", "13143499393");
		c.doClean();
	}

	// 静态内部类,没有外部类的引用，直接使用
	public static class Miehuoqi {
		public String brand;
		public int price;
	}
	// public void clean(String roomNo) {
	// class Cleaner {
	// private String name, tele;
	//
	// public Cleaner(String name, String tele) {
	// super();
	// this.name = name;
	// this.tele = tele;
	// }
	//
	// @Override
	// public String toString() {
	// return "保洁工 [name=" + name + ", tele=" + tele + "]";
	// }
	//
	// }
	// Date d = new Date();
	// Cleaner c = new Cleaner("王大妈", "13143499393");
	// System.out.println("在" + d + "," + c.name + "正在打扫：" + roomNo + ",在" +
	// name);
	// }
}
